package IT06;

import java.util.HashSet;

public class HashSetDemo {
    public static void main(String[] args) {
        HashSet<Student> hs = new HashSet<>();
        Student s1 = new Student("林青霞",18);
        Student s2 = new Student("王祖蓝",35);
        Student s3 = new Student("波士顿",33);
        Student s4 = new Student("波士顿",33);
        hs.add(s1);
        hs.add(s2);
        hs.add(s3);
        hs.add(s4);
        //s3与s4是同一个对象，要在输出时不重复，需要重写HashCode方法
        for (Student s : hs ){
            System.out.println(s.getName()+","+s.getAge());
        }
    }
}
